//
//  ByIndexVC.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/10.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByIndexVC.h"

@interface ByIndexVC () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *table;
@end

@implementation ByIndexVC

- (void)viewDidLoad {
    [super viewDidLoad];

    [self createTableView];
    self.title = @"ff";
    
    [self addBYItemviews:@[@"TagBar_shouye_selected"] mode:ByNavigationItemModeImageAndText position:ByNavigationItemPositionModeLeft];
    [self addBYItemviews:@[@"222", @"哈哈"] mode:ByNavigationItemModeText position:ByNavigationItemPositionModeRight];
    NSLog(@"11111");
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    [self setNaviAttributeWithTranslucent:true stateBarLightContent:true];
}

#pragma mark - createViews
- (void)createTableView {
    
    self.table = [[UITableView alloc] init];
    self.table.delegate = self;
    self.table.dataSource = self;
    [self.view addSubview:self.table];
    
    [self.table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view).insets(UIEdgeInsetsZero).priorityMedium();
        if (@available(iOS 11.0, *)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-49);
            make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft);
            make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight);
        }
    }];
    
    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 100)];
    header.backgroundColor = [UIColor redColor];
    self.table.tableHeaderView = header;

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%li", indexPath.row];

    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 80;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *header = [[UIView alloc] init];
    header.backgroundColor = [UIColor greenColor];
    return header;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return UIView.new;
}


- (void)rightItemsAction:(NSInteger)rightIndex {
    
    if (rightIndex == 0) {
        ByWebViewController *vc = [[ByWebViewController alloc] initWithTotalUrlString:@"https://gitee.com/13157396112GitHub/mijifen_ios/tree/master/mijifen_ios/"];
        [self by_normalPush:vc hasNavi:true];
    } else {
        // 模拟生成tabbar角标
//        [ByNotificationHandler tabbarBadgeModifyWithIndex:3 badge:3];
        
        ByViewCitySelect *view = [[ByViewCitySelect alloc] init];
        [view show];
    }
}

@end
